﻿/*!
* CAPICOM Cryptography Enumerations Javascript Shell
* Copyright 2014, Artem Yakovenko
* Site - https://cejss.codeplex.com
* Version - 1.0.0
*
* Date: Mon Aug 18 11:00:00 2014 +0400
*/

// http://msdn.microsoft.com/en-us/library/windows/desktop/aa380250(v=vs.85).aspx
// http://msdn.microsoft.com/en-us/library/hh524453.aspx

// http://msdn.microsoft.com/en-us/library/windows/desktop/aa375631(v=vs.85).aspx
var CAPICOM_ATTRIBUTE = {
    /// <field type='Number'>The attribute contains the time that the signature was created.</field>
    CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME: 0,
    /// <field type='Number'>The attribute contains the name of the signed document.</field>
    CAPICOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME: 1,
    /// <field type='Number'>The attribute contains a description of the signed document.</field>
    CAPICOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION: 2
};

// http://msdn.microsoft.com/en-us/library/windows/desktop/aa375642(v=vs.85).aspx
var CAPICOM_CERTIFICATE_FIND_TYPE = {
    /// <field type='Number'>Returns certificates matching a specified SHA1 hash.</field>
    CAPICOM_CERTIFICATE_FIND_SHA1_HASH: 0,
    /// <field type='Number'>Returns certificates whose subject name exactly or partially matches a specified subject name.</field>
    CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME: 1,
    /// <field type='Number'>Returns certificates whose issuer name exactly or partially matches a specified issuer name.</field>
    CAPICOM_CERTIFICATE_FIND_ISSUER_NAME: 2,
    /// <field type='Number'>Returns certificates whose root subject name exactly or partially matches a specified root subject name.</field>
    CAPICOM_CERTIFICATE_FIND_ROOT_NAME: 3,
    /// <field type='Number'>Returns certificates whose template name matches a specified template name.</field>
    CAPICOM_CERTIFICATE_FIND_TEMPLATE_NAME: 4,
    /// <field type='Number'>Returns certificates that have an extension that matches a specified extension.</field>
    CAPICOM_CERTIFICATE_FIND_EXTENSION: 5,
    /// <field type='Number'>Returns certificates that have an extended property whose property identifier matches a specified property identifier.</field>
    CAPICOM_CERTIFICATE_FIND_EXTENDED_PROPERTY: 6,
    /// <field type='Number'>Returns certificates in the store that have either an enhanced key usage extension or property combined with a usage identifier.</field>
    CAPICOM_CERTIFICATE_FIND_APPLICATION_POLICY: 7,
    /// <field type='Number'>Returns certificates containing a specified policy OID.</field>
    CAPICOM_CERTIFICATE_FIND_CERTIFICATE_POLICY: 8,
    /// <field type='Number'>Returns certificates whose time is valid.</field>
    CAPICOM_CERTIFICATE_FIND_TIME_VALID: 9,
    /// <field type='Number'>Returns certificates whose time is not yet valid.</field>
    CAPICOM_CERTIFICATE_FIND_TIME_NOT_YET_VALID: 10,
    /// <field type='Number'>Returns certificates whose time has expired.</field>
    CAPICOM_CERTIFICATE_FIND_TIME_EXPIRED: 11,
    /// <field type='Number'>Returns certificates containing a key that can be used in the specified manner.</field>
    CAPICOM_CERTIFICATE_FIND_KEY_USAGE: 12
};

// http://msdn.microsoft.com/en-us/library/windows/desktop/aa375647(v=vs.85).aspx
var CAPICOM_CERTIFICATE_INCLUDE_OPTION = {
    /// <field type='Number'>Saves all certificates in the chain with the exception of the root entity.</field>
    CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT: 0,
    /// <field type='Number'>Saves the complete certificate chain.</field>
    CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN: 1,
    /// <field type='Number'>Saves only the end entity certificate.</field>
    CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY: 2
};

// http://msdn.microsoft.com/en-us/library/windows/desktop/aa375743(v=vs.85).aspx
var CAPICOM_STORE_LOCATION = {
    /// <field type='Number'>The store is a memory store. Any changes in the contents of the store are not persisted.</field>
    CAPICOM_MEMORY_STORE: 0, 
    /// <field type='Number'>The store is a local machine store. Local machine stores can be read/write stores only if the user has read/write permissions. If the user has read/write permissions and if the store is opened read/write, then changes in the contents of the store are persisted.</field>
    CAPICOM_LOCAL_MACHINE_STORE : 1,
    /// <field type='Number'>The store is a current user store. A current user store may be a read/write store. If it is, changes in the contents of the store are persisted.</field>
    CAPICOM_CURRENT_USER_STORE: 2,
    /// <field type='Number'>The store is an Active Directory store. Active Directory stores can be opened only in read-only mode. Certificates cannot be added to or removed from Active Directory stores.</field>
    CAPICOM_ACTIVE_DIRECTORY_USER_STORE: 3,
    /// <field type='Number'>Stores support smart card–based certificate stores. The store is the group of present smart cards. Introduced in CAPICOM 2.0.</field>
    CAPICOM_SMART_CARD_USER_STORE: 4
};

// http://msdn.microsoft.com/en-us/library/windows/desktop/aa375673(v=vs.85).aspx
var CAPICOM_ENCODING_TYPE = {
    /// <field type='Number'>Data is saved as a base64-encoded string or a pure binary sequence. This encoding type is used only for input data that has an unknown encoding type. Introduced in CAPICOM 2.0.</field>
    CAPICOM_ENCODE_ANY: 0xffffffff,
    /// <field type='Number'>Data is saved as a base64-encoded string.</field>
    CAPICOM_ENCODE_BASE64: 0, 
    /// <field type='Number'>Data is saved as a pure binary sequence.</field>
    CAPICOM_ENCODE_BINARY: 1
};

//NOTE: not have enum in CAPICOM 2.0
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa388130(v=vs.85).aspx
var CAPICOM_STORE_NAME = {
    /// <field type='String'>CA store. This store is used to store intermediate CA certificates.</field>
    CAPICOM_CA_STORE: "Ca",
    /// <field type='String'>My store. This store is used for a user's personal certificates.</field>
    CAPICOM_MY_STORE: "My",
    /// <field type='String'>AddressBook store. This store is used to keep the certificates of others.</field>
    CAPICOM_OTHER_STORE: "AddressBook",
    /// <field type='String'>Root store. This store is used to store the root CA and self-signed, trusted certificates.</field>
    CAPICOM_ROOT_STORE: "Root"
};

// http://msdn.microsoft.com/en-us/library/windows/desktop/aa375747(v=vs.85).aspx
var CAPICOM_STORE_OPEN_MODE = {
    /// <field type='Number'>Open the store in read-only mode.</field>
    CAPICOM_STORE_OPEN_READ_ONLY: 0, 
    /// <field type='Number'>Open the store in read/write mode.</field>
    CAPICOM_STORE_OPEN_READ_WRITE: 1, 
    /// <field type='Number'>Open the store in read/write mode if the user has read/write permissions. If the user does not have read/write permissions, open the store in read-only mode.</field>
    CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED: 2, 
    /// <field type='Number'>Open existing stores only; do not create a new store. Introduced by CAPICOM 2.0.</field>
    CAPICOM_STORE_OPEN_EXISTING_ONLY: 128, 
    /// <field type='Number'>Include archived certificates when using the store. Introduced by CAPICOM 2.0.</field>
    CAPICOM_STORE_OPEN_INCLUDE_ARCHIVED: 256
};